package extend;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JdbcDemo {

    public static void main(String[] args) throws SQLException {


        Connection conn = DriverManager.getConnection("jdbc:mysql://doitedu:3306/doit46", "root", "root");

        PreparedStatement preparedStatement = conn.prepareStatement(
                "insert into user_action_count (user_id,event_id,event_cnt) values (?,?,?)  on DUPLICATE KEY UPDATE event_cnt = ?  ");

        preparedStatement.setInt(1,10);
        preparedStatement.setString(2,"A");
        preparedStatement.setLong(3,2000);
        preparedStatement.setLong(4,2000);

        preparedStatement.execute();


        preparedStatement.setInt(1,12);
        preparedStatement.setString(2,"B");
        preparedStatement.setLong(3,3000);
        preparedStatement.setLong(4,3000);

        preparedStatement.execute();


    }

}
